package sequences;

import java.util.Date;
import java.util.Random;

/**
 * A character sequence generator based on sine functions.
 * 
 * @author John Schaeffer
 *
 */
public class SineSequence implements CharSequence {

    private int time = 0;
    private Random rng = new Random(new Date().getTime());
    
    public char nextChar() {
        
        char maxChar = 0;
        double maxVal = -2;
        
        for(char i = 0; i < 26; i++) {
            double temp = Math.sin(Math.exp((double)i+time) + rng.nextDouble());
            if(temp > maxVal) {
                maxVal = temp;
                maxChar = (char)(i + 'A');
            }
        }
        
        time = (time + 1) % 10;
        
        return maxChar;
    }

}
